package view;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.dbu;

/**
 * Servlet implementation class hello
 */
@WebServlet("/helloworld")
public class hello extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public hello() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
		String valueone = request.getParameter("first");
		String valuetwo = request.getParameter("second");
		
        String j="false";
		
		String sql1="Insert into stu(first,second)";
		String sql2="values("+valueone+","+valuetwo+")";
		String sql=sql1+sql2;
		dbu run=new dbu();
		int n=run.updateSQL(sql);
		if(n>=1)
			//j="true";
			response.sendRedirect("/JEEDemo/succeed.jsp");
		else
			//j="false";
			response.sendRedirect("/JEEDemo/error.jsp");
		//if("qqq".equals(valueone)&&"www".equals(valuetwo)){
		//	response.sendRedirect("/JEEDemo/succeed.jsp");
		//}else{
		//	response.sendRedirect("/JEEDemo/error.jsp");

		//}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
